<?php
if (!(defined('IN_IA')))
{
    exit('Access Denied');
}
/**
 * User: 邓志锋 <280160522@qq.com> <http://www.diygw.com>
 * Date: 2018-07-28
 * Time: 下午 6:06
 */
class Admin_Diygwcom extends DiygwcomAction
{
    public function index()
    {
        global $_GPC, $_W;
        $dashboardid=safe_gpc_string($_GPC['pid']);
        $dashboard = pdo_getall(getTableName('DASHBOARD'), array('uniacid'=>$_W['uniacid']), array('title', 'id'));
        $src="#";
        foreach ($dashboard as $key => $item ){
            if($item['id']==$dashboardid){
                $dashboardtitle=$item['title'];
            }
        }
        $template = safe_gpc_string($_GPC["template"]);
        $dashboardpage = pdo_getall(getTableName('PAGE'), array('dashboard_id'=>$dashboardid,'template'=>$template), array('id','dashboard_id','name','title','scene_id','template_type','template','is_home','update_time','orderlist','create_time'),'',array('is_home desc','orderlist asc'));
        if(!empty($dashboardpage)&&is_array($dashboardpage)>0){
            if($template=='mobile'){
                $src=DiygwcomUtil::to_mobile_url($this->createMobileUrl('page_index', array('m'=>'diygwcom_app','pid'=>$dashboardpage[0]["id"])));
            }else{
                $src=$this->createWebUrl('page_index', array('m'=>'diygwcom_app','pid'=>$dashboardpage[0]["id"]));
            }
        }
        include $this->template();
    }


}